#region File Description
//-----------------------------------------------------------------------------
// OptionsMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace ManagerGame
{
    /// <summary>
    /// The options screen is brought up over the top of the main menu
    /// screen, and gives the user a chance to configure the game
    /// in various hopefully useful ways.
    /// </summary>
    class OptionsMenuScreen : MenuScreen
    {
        #region Fields
        MenuEntry resources;
        MenuEntry timeMenuEntry;
       
        static int[] money = { 50000, 100000, 500000};
        static int currentResources = 0;

        static int[] weeks = {1, 4, 10 };

        static int currentWeeks = 0;
        //static bool frobnicate = true;

        static int elf = 23;

        #endregion

        #region Initialization


        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            resources = new MenuEntry(string.Empty);
            timeMenuEntry = new MenuEntry(string.Empty);


            //elfMenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Hook up menu event handlers.
            resources.Selected += ResourcesMenuEntrySelected;
            timeMenuEntry.Selected += TimeMenuEntrySelected;
            
            //elfMenuEntry.Selected += ElfMenuEntrySelected;
            back.Selected += OnCancel;
            
            // Add entries to the menu.
            MenuEntries.Add(resources);
            MenuEntries.Add(timeMenuEntry);
           
            //MenuEntries.Add(elfMenuEntry);
            MenuEntries.Add(back);
        }


        /// <summary>
        /// Fills in the latest values for the options screen menu text.
        /// </summary>
        void SetMenuEntryText()
        {
            resources.Text = "Money: " + money[currentResources];
            timeMenuEntry.Text = "Time: " + weeks[currentWeeks] + " weeks"; //(frobnicate ? "on" : "off");
            //elfMenuEntry.Text = "elf: " + elf;
        }


        #endregion

        #region Handle Input


 


        /// <summary>
        /// Event handler for when the Language menu entry is selected.
        /// </summary>
        void ResourcesMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentResources = (currentResources + 1) % money.Length;
            
            SetMenuEntryText();

            SetResources(money[currentResources]);
        }


        private void SetResources(int money)
        {
            
            Options.Money = money;
        }

        /// <summary>
        /// Event handler for when the Frobnicate menu entry is selected.
        /// </summary>
        void TimeMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            currentWeeks = (currentWeeks + 1) % weeks.Length;

            SetMenuEntryText();
        }


        /// <summary>
        /// Event handler for when the Elf menu entry is selected.
        /// </summary>
        void ElfMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            elf++;

            SetMenuEntryText();
        }


        #endregion
    }
}
